package com.hzhr.iot.user.sdk.constant;

import com.hzhr.iot.core.constant.HttpExceptionCategory;
import com.hzhr.iot.core.constant.ServiceErrors;
import com.hzhr.iot.core.constant.ServiceExceptionCategory;
import org.springframework.http.HttpStatus;
import org.springframework.util.StringUtils;

public enum User_ErrorsEnum implements ServiceErrors {
    //region CompanyService
    //region post
    COMPANYSERVICE_POST_201(201, "系统权限 : 根据公司名称查询公司“公司_1”,如果“公司_1”存在，抛出异常“公司名称已存在”", "公司名称已存在", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    COMPANYSERVICE_POST_202(202, "判断公司名称的合法性", "公司名称不合法", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    //endregion
    //region deleteById
    COMPANYSERVICE_DELETE_BY_ID_201(201, "判断用户是否具备删除该公司的条件", "用户不具备删除该公司的条件", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    //endregion
    //region patchBasicInfoById
    COMPANYSERVICE_PATCH_BASIC_INFO_BY_ID_201(201, "判断用户是否具备更新该公司基本信息的条件", "用户不具备更新该公司基本信息的条件", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    //endregion
    //endregion

    //region Company_BasicInfoService
    //region put
    COMPANY_BASICINFOSERVICE_PUT_201(201, "查询公司", "公司不存在", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    //endregion
    //region post
    COMPANY_BASICINFOSERVICE_POST_201(201, "验证登录人类型", "登录人不是游离用户，无法进行操作", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    COMPANY_BASICINFOSERVICE_POST_202(202, "验证公司名称", "公司名称已存在", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),

    //endregion

    //endregion

    //region Dept_NameService
    //region put
    DEPT_NAMESERVICE_PUT_201(201, "查询部门", "部门不存在", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    DEPT_NAMESERVICE_PUT_202(202, "验证部门名称的合法性", "部门名称重复，无法修改", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    //endregion

    //endregion

    //region Dept_ParentIdService
    //region put
    DEPT_PARENTIDSERVICE_PUT_201(201, "查询部门", "部门不存在", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    DEPT_PARENTIDSERVICE_PUT_202(202, "查询上级部门", "上级部门不存在", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    DEPT_PARENTIDSERVICE_PUT_203(203, "验证部门是否具备更新上级部门编号的条件", "部门名称在新的上级部门下已存在，无法进行该操作", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    DEPT_PARENTIDSERVICE_PUT_204(204, "验证部门是否具备更新上级部门编号的条件", "部门存在下级部门或下级用户，无法进行该操作", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),

    //endregion

    //endregion

    //region DeptService
    //region post
    DEPTSERVICE_POST_201(201, "验证上级部门", "上级部门不存在", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    DEPTSERVICE_POST_202(202, "验证部门名称", "部门名称已存在", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    //endregion
    //region deleteById
    DEPTSERVICE_DELETE_BY_ID_201(201, "查询部门", "部门不存在", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    DEPTSERVICE_DELETE_BY_ID_202(202, "验证部门是否具备删除条件", "存在下级部门或下级用户，无法删除", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    //endregion
    //endregion

    //region ResourceService
    //region post
    RESOURCESERVICE_POST_201(201, "判断是否已经存在具有相同服务、版本及uri的资源", "已经存在具有相同服务、版本及uri的资源", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    //endregion

    //region postActionResources
    RESOURCESERVICE_POST_ACTION_RESOURCES_201(201, "判断该动作下是否已经存在要新增的资源", "该动作下已存在要新增的资源", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    //endregion
    //region putActionResourceById
    RESOURCESERVICE_PUT_ACTION_RESOURCES_BY_ID_201(201, "更新动作下的资源", "动作下不存在该资源", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    //endregion
    //endregion

    //region ActionService
    //region putById
    ACTIONSERVICE_PUT_BY_ID_201(201, "更新动作", "动作不存在", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    //endregion

    //region postRoleAction
    ACTIONSERVICE_POST_ROLE_ACTION_201(201, "判断用户是否具备在角色下新增该动作的条件", "用户不具备在该角色下新增该动作的条件", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    ACTIONSERVICE_POST_ROLE_ACTION_202(202, "判断该角色下是否已经存在要新增的动作", "该角色下已存在要新增的动作", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    //endregion
    //region deleteRoleActionById
    ACTIONSERVICE_DELETE_ROLE_ACTION_BY_ID_201(201, "判断用户是否具备在角色下删除该动作的条件", "用户不具备在该角色下删除该动作的条件", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    //endregion
    //endregion

    //region RoleService
    //region get1
    ROLESERVICE_GET1_201(201, "查询角色", "登录用户的所属公司不存在", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    //endregion
    //region post
    ROLESERVICE_POST_201(201, "判断角色名称是否已经存在", "角色名称已存在", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    //endregion
    //region deleteById
    ROLESERVICE_DELETE_BY_ID_201(201, "判断登录用户是否具备删除该角色的条件", "登录用户不具备删除该角色的条件", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    //endregion
    //region putById
    ROLESERVICE_PUT_BY_ID_201(201, "判断登录用户是否具备更新该角色的条件", "登录用户不具备更新该角色的条件", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    ROLESERVICE_PUT_BY_ID_202(202, "判断更新后的角色名称是否已经存在", "新角色名称已经存在", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    //endregion

    //region postUserRole
    ROLESERVICE_POST_USER_ROLE_201(201, "判断登录用户是否具备在该用户下新增该角色的条件", "登录用户不具备在该用户下新增该角色的条件", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    ROLESERVICE_POST_USER_ROLE_202(202, "判断该用户下是否已经存在要新增的角色", "该用户下已存在要新增的角色", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    //endregion
    //region deleteUserRoleById
    ROLESERVICE_DELETE_USER_ROLE_BY_ID_201(201, "判断登录用户是否具备在删除该用户下的该角色的条件", "登录用户不具备在删除该用户下的该角色的条件", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    //endregion
    //endregion

    //region TokenService
    //region get
    TOKENSERVICE_GET_201(201, "认证用户", "用户不存在或密码不匹配", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    //endregion
    //endregion

    //region User_RegistInfoService
    //region post
    USER_REGISTINFOSERVICE_POST_201(201, "判断手机号的唯一性", "手机号已注册", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    //endregion

    //endregion

    //region User_BasicInfoService
    //region put
    USER_BASICINFOSERVICE_PUT_201(201, "查询用户", "用户不存在", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    //endregion

    //endregion

    //region User_MoreCompleteRegistInfoService
    //region put
    USER_MORECOMPLETEREGISTINFOSERVICE_PUT_201(201, "判断用户状态", "非新用户，无法进行该操作", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    USER_MORECOMPLETEREGISTINFOSERVICE_PUT_202(202, "判断公司是否存在", "公司不存在", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),

    //endregion

    //endregion

    //region User_RskeyService
    //region put
    USER_RSKEYSERVICE_PUT_201(201, "查询用户", "用户不存在", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    //endregion

    //endregion

    //region User_SysInfoService
    //region put
    USER_SYSINFOSERVICE_PUT_BY_ID_201(201, "验证角色的合法性", "角色不合法", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    USER_SYSINFOSERVICE_PUT_BY_ID_202(202, "查询用户", "用户不存在", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),
    USER_SYSINFOSERVICE_PUT_BY_ID_203(203, "验证新的部门编号的合法性", "新的部门不存在", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),

    //endregion

    //endregion

    //region User_PasswordService
    //region putByUserId
    USER_PASSWORDSERVICE_PUT_BY_USER_ID_201(201, "查询用户", "用户不存在", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN),

    //endregion

    //endregion

    //region UserService
    //region get
    USERSERVICE_GET_101(101, null, "query.count不能大于100", ServiceExceptionCategory.ARG_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.BAD_REQUEST);
    //endregion
    //endregion



    private Integer code;
    private String messaeg;
    private String business;
    private ServiceExceptionCategory serviceExceptionCategory;
    private HttpExceptionCategory httpExceptionCategory;
    private HttpStatus httpStatus;
    User_ErrorsEnum(Integer code, String business, String message, ServiceExceptionCategory serviceExceptionCategory, HttpExceptionCategory httpExceptionCategory, HttpStatus httpStatus) {
        this.code = code;
        this.business = business;
        this.messaeg = message;
        this.serviceExceptionCategory = serviceExceptionCategory;
        this.httpExceptionCategory = httpExceptionCategory;
        this.httpStatus = httpStatus;
    }
    @Override
    public Integer getCode() {
        return code;
    }
    @Override
    public String getBusiness() {
        return business;
    }
    @Override
    public String getMessage() {
        return messaeg;
    }
    @Override
    public ServiceExceptionCategory getServiceExceptionCategory() {
        return serviceExceptionCategory;
    }
    @Override
    public HttpExceptionCategory getHttpExceptionCategory() {
        return httpExceptionCategory;
    }
    @Override
    public HttpStatus getHttpStatus() {
        return httpStatus;
    }
    @Override
    public void setMessage(String message) {
        this.messaeg = message;
    }

    public static User_ErrorsEnum getEnumByName(String name) {
        if (StringUtils.isEmpty(name)) return null;
        for (User_ErrorsEnum user_errorsEnum : User_ErrorsEnum.values()) {
            if (user_errorsEnum.name().equals(name)) {
                return user_errorsEnum;
            }
        }
        return null;
    }
}

